Repository navigation
fix(minimax-bot): 文件名带 .. 的上传不再永久附加不上 - #148
Open
Apageoflove wants to merge 1 commit into
Open
Apageoflove wants to merge 1 commit into
Apageoflove wants to merge 1 commit into
Conversation
Apageoflove
force-pushed
the
fix/minimax-bot-upload-name
branch
2 times, most recently
from
November 20, 2026 01:23
a46eb25 to
ff5c9e6
Compare
safeUploadName 只替换了少数禁用字符,于是 report..final.txt 这类名字原样 成为上传 id 的一部分;而 engine 的 resolveAttachments 明确拒绝含 .. 的 id, 这份附件从此永远附加不上,消息发送失败但上传本身看起来是成功的。 两处收紧:连续的点替换成一个下划线(单个点保留,扩展名不受影响), 超长名字按码位而不是 UTF-16 单元切开,避免把 emoji 劈成孤立代理。 新测试走真实 /api/uploads,断言返回的 id 不含 .. 且能通过 UPLOAD_NAME_RE, 普通文件名保持原样。在 0.7.28 上红、在切片上绿。全量 414 条通过。
Apageoflove
force-pushed
the
fix/minimax-bot-upload-name
branch
from
November 20, 2026 06:27
ff5c9e6 to
d352150
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
上传一个名字里带两个点的文件,上传本身会成功,之后却永远附加不上。
safeUploadName 只把少数几个禁用字符换成下划线,report..final.txt 这种名字原样成了上传 id 的一部分。而 engine 判附件时明确拒绝任何含 .. 的 id,所以这份文件上传那一刻就已经废了。用户看到的是上传成功、发消息失败,再试一次也一样。
同一个函数还有一处:名字超过 140 个 UTF-16 单元时按单元切,一个 emoji 正好被劈成两半,留下孤立代理。现在改成按码位切,并且守住 140 的长度预算。
连续的点替换成一个下划线,单个点保留,扩展名不受影响;前导点还是照旧剥掉。测了几个边界:report..final.txt 变成 report_final.txt,a.pdf 不变,.gitignore 变成 gitignore,80 个 emoji 的名字切完没有孤立代理。
测试走真实 /api/uploads:断言返回的 id 不含 .. 且能通过 UPLOAD_NAME_RE,同时确认 notes.txt 这种普通名字保持原样。在 0.7.28 上红、在切片上绿。全量 414 条过。
版本号到 0.7.34。0.7.29 到 0.7.33 被另外五条还开着的 PR 占着。
这次只动了上传名字的清洗,没有改 serveUpload 或 resolveAttachments 的判定。也就是说已经在磁盘上、id 里带 .. 的旧文件还是附加不了,那些得等用户重新上传。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.